//检测缓冲区类型和大小
// ./buf_test <in.txt> out.txt 2 >err.txt   这是执行
// 分为 ./buf_test <in.txt
//      >out.txt
//      2 > err.txt

#include <stdio.h>
int main()
{
    printf("stdin is ");
    if (stdin->_flags & _IO_UNBUFFERED) //判断标准输入流对象的缓冲区类型
        printf("unbuffered\n");         //无缓存
    else if (stdin->_flags & _IO_LINE_BUF)
        printf("line-buffered\n"); //行缓存
    else
        printf("fullyj-buffered\n");                                         //全缓存
    printf("buffer size is %d\n", stdin->_IO_buf_end - stdin->_IO_buf_base); //打印缓冲区的大小

    printf("file discriptor is %d\n\n", fileno(stdin)); //标准输入流的文件描述符
    printf("stdout is ");
    if (stdout->_flags & _IO_UNBUFFERED) //判断标准输入流对象的缓冲区类型
        printf("unbuffered\n");          //无缓存
    else if (stdout->_flags & _IO_LINE_BUF)
        printf("line-buffered\n"); //行缓存
    else
        printf("fully-buffered\n");                                            //全缓存
    printf("buffer size is %d\n", stdout->_IO_buf_end - stdout->_IO_buf_base); //打印缓冲区的大小
    printf("file discriptor is %d\n\n", fileno(stdout));                       //标准输出流的文件描述符

    printf("stderr is ");
    if (stderr->_flags & _IO_UNBUFFERED) //判断标准出错流对象的缓冲区类型
        printf("unbuffered\n");          //无缓存
    else if (stderr->_flags & _IO_LINE_BUF)
        printf("line-buffered\n"); //行缓存
    else
        printf("fully-buffered\n");                                            //全缓存
    printf("buffer size is %d\n", stderr->_IO_buf_end - stderr->_IO_buf_base); //打印缓冲区的大小
    printf("file discriptor is %d\n\n", fileno(stderr));
    return 0;
}